﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.OleDb;

public partial class UserConTrols_4Hang_Moi : System.Web.UI.UserControl
{
    DataProvider duLieu = new DataProvider();
    ListBox listBox = new ListBox();

    protected void Page_Load(object sender, System.EventArgs e)
    {
        if (!IsPostBack)
        {
            DataTable bangsach = new DataTable();
            DataTable bangsach1 = new DataTable();
            bangsach = duLieu.Load_Du_Lieu_New("SELECT TOP 6 NHOMHANGHOA.*, LOAIHANGHOA.TENLOAIHH, HANGHOA.*, NHASX.TENNHASX FROM NHASX INNER JOIN HANGHOA ON NHASX.MANHASX = HANGHOA.MANHASX INNER JOIN LOAIHANGHOA ON HANGHOA.MALOAIHH = LOAIHANGHOA.MALOAIHH INNER JOIN NHOMHANGHOA ON LOAIHANGHOA.MANHOMHH = NHOMHANGHOA.MANHOMHH ORDER BY ngaynhap DESC;", listBox);

            if (bangsach.Rows.Count != 0)
            {
                DataList1.DataSource = bangsach;
                DataList1.DataBind();
            }
            else
            {
                showthongbaosachmoi.Text = duLieu.BangThongBao("THÔNG BÁO", "<a href='Default.aspx'>HIỆN TẠI SIÊU THỊ HẾT HÀNG. MONG QUÝ KHÁCH THÔNG CẢM</a>");
            }

        }
    }
    public string Lay_DATE_Chuan_VN(string DuLieu)
    {
        return System.DateTime.Parse(DuLieu).Day + "/" + System.DateTime.Parse(DuLieu).Month + "/" + System.DateTime.Parse(DuLieu).Year;
    }

    public string rutgonten(string noidung, int chieudai, int kieu)
    {
        //=== Nếu Kiểu = 1 => Có DIV
        //=== Nếu Kiểu = 2 => Ko Có DIV
        if (kieu == 1)
        {
            return "<div title='" + noidung + "'>" + (noidung.Length > chieudai ? noidung.Substring(0, chieudai-1) + "..." : noidung) + "</div>";
        }
        else if (kieu == 2)
        {
            return (noidung.Length > chieudai ? noidung.Substring(0, chieudai-1) + "..." : noidung);
        }
        else
        {
            return "0";
        }
    }
}